import {BrowserRouter,Routes,Route,useNavigate} from "react-router-dom";
import {Suspense,lazy} from "react";

const Login = lazy( () => import('../pages/login') )

export const Router = () => {
    return (
        <BrowserRouter>
            <Suspense fallback={<div>Loading...</div>}>
                <Routes>
                    {
                        localStorage.getItem('token')===undefined ?
                        (<Route path={'/'} element={Login}></Route>) :
                        (
                            <Route path={'/'} element={Home}></Route>
                        )
                    }
                </Routes>
            </Suspense>
        </BrowserRouter>
    )
}
